package com.workerhelping.vo;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.workerhelping.enums.PoliticsStatusEnum;
import com.workerhelping.enums.StatusEnum;
import com.workerhelping.enums.StuckReasonEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PreviewRecordVO {
    private Integer id;
    // 姓名
    private String name;
    // 民族
    private String nation;
    // 性别
    private String gender;
    // 政治面貌,对应PoliticsStatusEnum
    private Integer politicsStatus;
    private String politicsStatusStr;
    // 身份证号
    private String idNumber;
    // 出生日期
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date birthday;
    // 年两
    private Integer age;
    // 是否健康
    private Integer healthStatus;
    private String healthStatusStr;
    // 疾病类别（可选）
    private String illness;
    // 是否在岗
    private Integer workStatus;
    private String workStatusStr;
    // 年收入（万/年）
    private Integer salary;
    // 住房面积（可选）
    private Integer livingSpace;
    // 电话号码
    private String phoneNumber;
    // 邮箱（可选）
    private String email;
    // 是否结婚
    private Integer maritalStatus;
    private String maritalStatusStr;
    // 医保状况
    private Integer insuranceStatus;
    private String insuranceStatusStr;
    // 邮编
    private String postcode;
    // 工作单位
    private String workUnit;
    // 银行卡号
    private String creditCardNumbers;
    // 附件上传（可选）
    private String attachFile;
    // 致困原因
    private List<Integer> stuckReasonIds;
    private List<String> stuckReasonStr;
    // 职工id
    private Integer wId;

    public String getPoliticsStatusStr() {
        return PoliticsStatusEnum.getStatusName(this.politicsStatus);
    }

    public String getHealthStatusStr() {
        return StatusEnum.getStatusName(this.healthStatus);
    }

    public String getWorkStatusStr() {
        return StatusEnum.getStatusName(this.workStatus);
    }

    public String getMaritalStatusStr() {
        return StatusEnum.getStatusName(this.maritalStatus);
    }

    public String getInsuranceStatusStr() {
        return StatusEnum.getStatusName(this.insuranceStatus);
    }

    public Integer getAge() {
        String now = new SimpleDateFormat("yyyy").format(new Date());
        String bir = new SimpleDateFormat("yyyy").format(this.birthday);
        return Integer.parseInt(now) - Integer.parseInt(bir);
    }

    public List<String> getStuckReasonStr() {
        ArrayList<String> reasons = new ArrayList<>();
        Integer stuckReasonId = this.getStuckReasonIds().get(0);
        reasons.add(StuckReasonEnum.getStuckReasonName(stuckReasonId));
        return reasons;
    }
}
